import { IPSDEGridEditItemVR } from './ipsdegrid-edit-item-vr';
import { IPSDEFValueRule } from '../../dataentity/defield/valuerule/ipsdefvalue-rule';
import { IPSSysValueRule } from '../../valuerule/ipssys-value-rule';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEGridEditItemVRImpl extends PSModelObjectImpl implements IPSDEGridEditItemVR {
  get checkMode(): 1 | 2 | 3 {
    return this.M.checkMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefvaluerule: IPSDEFValueRule | null = null;

  getPSDEFValueRule(): IPSDEFValueRule | null {
    if (this.psdefvaluerule != null) return this.psdefvaluerule;
    const value = this.M.getPSDEFValueRule;
    if (value == null) {
      return null;
    }
    this.psdefvaluerule = this.getPSModel4('dataentity.defield.valuerule.IPSDEFValueRule', value, 'getPSDEFValueRule') as IPSDEFValueRule;
    return this.psdefvaluerule;
  }

  get psDEFValueRule(): IPSDEFValueRule | null {
    return this.getPSDEFValueRule();
  }

  getPSDEFValueRuleMust(): IPSDEFValueRule {
    const value = this.getPSDEFValueRule();
    if (value == null) {
      throw new Error('未指定属性值规则 ');
    }
    return value;
  }

  get psDEGridEditItemName(): string {
    return this.M.getPSDEGridEditItemName;
  }

  getPSDEGridEditItemName(): string {
    return this.M.getPSDEGridEditItemName;
  }

  protected pssysvaluerule: IPSSysValueRule | null = null;

  getPSSysValueRule(): IPSSysValueRule | null {
    if (this.pssysvaluerule != null) return this.pssysvaluerule;
    const value = this.M.getPSSysValueRule;
    if (value == null) {
      return null;
    }
    this.pssysvaluerule = this.getPSModel4('valuerule.IPSSysValueRule', value, 'getPSSysValueRule') as IPSSysValueRule;
    return this.pssysvaluerule;
  }

  get psSysValueRule(): IPSSysValueRule | null {
    return this.getPSSysValueRule();
  }

  getPSSysValueRuleMust(): IPSSysValueRule {
    const value = this.getPSSysValueRule();
    if (value == null) {
      throw new Error('未指定系统值规则');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get valueRuleType(): 'DEFVALUERULE' | 'SYSVALUERULE' {
    return this.M.valueRuleType;
  }

  get cls(): string {
    return 'PSDEGridEditItemVRImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.grid.IPSDEGridEditItemVR') return true;
    return super.instanceof(cls);
  }
}
